﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DataReader
{
    public class GCN
    {
        /// <summary>
        /// Creates hash of string (Thanks to blank and NWPlayer123 for this function)
        /// </summary>
        public static ushort CreateHash(string str)
        {
            byte[] dat = Encoding.GetEncoding("shift-jis").GetBytes(str);
            ushort h = 0;
            for (int i = 0; i < dat.Length; i++)
                h = (ushort)(h * 3 + dat[i]);
            return h;
        }
        public static ushort CreateHash(byte[] dat)
        {
            ushort h = 0;
            for (int i = 0; i < dat.Length; i++)
                h = (ushort)(h * 3 + (byte)dat[i]);
            return h;
        }
    }
}
